﻿using System;

namespace geFormRevI
{
    public delegate void geClickHandler(object sender, geClickArgs e);
    public class geClickArgs : EventArgs
    {

        public int button
        {
            get
            {
                return button;
            }
            private set
            {
                button = value;
            }
        }
        public int clientX
        {
            get
            {
                return clientX;
            }
            private set
            {
                clientX = value;
            }
        }
        public int clientY
        {
            get
            {
                return clientY;
            }
            private set
            {
                clientY = value;
            }
        }
        public int screenX
        {
            get
            {
                return screenX;
            }
            private set
            {
                screenX = value;
            }
        }
        public int screenY
        {
            get
            {
                return screenY;
            }
            private set
            {
                screenY = value;
            }
        }
        public float latitude
        {
            get
            {
                return latitude;
            }
            private set
            {
                latitude = value;
            }
        }
        public float longitude
        {
            get
            {
                return longitude;
            }
            private set
            {
                longitude = value;
            }
        }
        public float altitude
        {
            get
            {
                return altitude;
            }
            private set
            {
                altitude = value;
            }
        }
        public bool didHitGlobe
        {
            get
            {
                return didHitGlobe;
            }
            private set
            {
                didHitGlobe = value;
            }
        }
        public bool altKey
        {
            get
            {
                return altKey;
            }
            private set
            {
                altKey = value;
            }
        }
        public bool ctrlKey
        {
            get
            {
                return ctrlKey;
            }
            private set
            {
                ctrlKey = value;
            }
        }
        public bool shiftKey
        {
            get
            {
                return shiftKey;
            }
            private set
            {
                shiftKey = value;
            }
        }
        public object relatedTarget
        {
            get
            {
                return relatedTarget;
            }
            private set
            {
                relatedTarget = value;
            }
        }

        public geClickArgs(string button, string clientX, string clientY, string screenX, string screenY, string latitude, string longitude, string altitude, string didHitGlobe, string altKey, string ctrlKey, string shiftKey, object relatedTarget)
        {
            this.button = stringToInt(button);
            this.clientX = stringToInt(clientX);
            this.clientY = stringToInt(clientY);
            this.screenX = stringToInt(screenX);
            this.screenY = stringToInt(screenY);
            this.latitude = stringToFloat(latitude);
            this.longitude = stringToFloat(longitude);
            this.altitude = stringToFloat(altitude);
            this.didHitGlobe = stringToBool(didHitGlobe);
            this.altKey = stringToBool(altKey);
            this.ctrlKey = stringToBool(ctrlKey);
            this.shiftKey = stringToBool(shiftKey);
            this.relatedTarget = relatedTarget;

        }
        private static bool stringToBool(string args)
        {
            try
            {
                return bool.Parse(args);
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        private static float stringToFloat(string args)
        {
            try
            {
                return float.Parse(args);
            }
            catch (Exception ex)
            {
                return 0;
            }
        }
        private static int stringToInt(string args)
        {
            try
            {
                return Int32.Parse(args);
            }
            catch (Exception ex)
            {
                return 0;
            }
        }
    }
}
